/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author itachiu
 */
@Entity
@Table(name = "pet")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Pet.findAll", query = "SELECT p FROM Pet p"),
    @NamedQuery(name = "Pet.findByIdPET", query = "SELECT p FROM Pet p WHERE p.petPK.idPET = :idPET"),
    @NamedQuery(name = "Pet.findByName", query = "SELECT p FROM Pet p WHERE p.name = :name"),
    @NamedQuery(name = "Pet.findBySpecies", query = "SELECT p FROM Pet p WHERE p.species = :species"),
    @NamedQuery(name = "Pet.findByAge", query = "SELECT p FROM Pet p WHERE p.age = :age"),
    @NamedQuery(name = "Pet.findByWeight", query = "SELECT p FROM Pet p WHERE p.weight = :weight"),
    @NamedQuery(name = "Pet.findByImage", query = "SELECT p FROM Pet p WHERE p.image = :image"),
    @NamedQuery(name = "Pet.findByOwnerPersonPersonId", query = "SELECT p FROM Pet p WHERE p.petPK.ownerPersonPersonId = :ownerPersonPersonId"),
    @NamedQuery(name = "Pet.findByMEDICALRECORDidMEDICALRECORD", query = "SELECT p FROM Pet p WHERE p.petPK.mEDICALRECORDidMEDICALRECORD = :mEDICALRECORDidMEDICALRECORD")})
public class Pet implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected PetPK petPK;
    @Column(name = "NAME")
    private String name;
    @Column(name = "SPECIES")
    private String species;
    @Column(name = "AGE")
    private Integer age;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "WEIGHT")
    private Float weight;
    @Column(name = "IMAGE")
    private String image;
    @JoinColumn(name = "MEDICAL_RECORD_idMEDICAL_RECORD", referencedColumnName = "idMEDICAL_RECORD", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private MedicalRecord medicalRecord;
    @JoinColumn(name = "OWNER_PERSON_PERSON_ID", referencedColumnName = "PERSON_PERSON_ID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Owner owner;

    public Pet() {
    }

    public Pet(PetPK petPK) {
        this.petPK = petPK;
    }

    public Pet(int idPET, int ownerPersonPersonId, int mEDICALRECORDidMEDICALRECORD) {
        this.petPK = new PetPK(idPET, ownerPersonPersonId, mEDICALRECORDidMEDICALRECORD);
    }

    public PetPK getPetPK() {
        return petPK;
    }

    public void setPetPK(PetPK petPK) {
        this.petPK = petPK;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSpecies() {
        return species;
    }

    public void setSpecies(String species) {
        this.species = species;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Float getWeight() {
        return weight;
    }

    public void setWeight(Float weight) {
        this.weight = weight;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public MedicalRecord getMedicalRecord() {
        return medicalRecord;
    }

    public void setMedicalRecord(MedicalRecord medicalRecord) {
        this.medicalRecord = medicalRecord;
    }

    public Owner getOwner() {
        return owner;
    }

    public void setOwner(Owner owner) {
        this.owner = owner;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (petPK != null ? petPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Pet)) {
            return false;
        }
        Pet other = (Pet) object;
        if ((this.petPK == null && other.petPK != null) || (this.petPK != null && !this.petPK.equals(other.petPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.Pet[ petPK=" + petPK + " ]";
    }
    
}
